
/**
* @Title: ThreadTest.java
* @Package com.leetone
* @Description: 【】
* @date 2018年8月27日 下午6:39:25
* @version V1.0
* @Company: 上海未泰信息技术有限公司
* @author:[谭磊][leetone123@163.com]
*/

package com.leetone;


/**
* @ClassName: ThreadTest
* @Description: 【线程调用测试】
* @date 2018年8月27日 下午6:39:25
* @Company: 上海未泰信息技术有限公司
* @author:[谭磊][leetone123@163.com]
*/

public class ThreadPriority implements Runnable{
	@Override
	public void run() {
		try {
			Thread.sleep(10000L);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Thread mainThread = Thread.currentThread();
		System.out.println("线程名称：\t"+mainThread.getName());
		System.out.println("线程组活动线程数：\t"+Thread.activeCount());
		System.out.println("线程标识符：\t"+mainThread.getId());
		System.out.println("线程优先级：\t"+mainThread.getPriority());
		System.out.println("线程状态：\t"+mainThread.getState());
		System.out.println("线程所在线程组：\t"+mainThread.getThreadGroup());
		System.out.println("线程是否处于活动状态：\t"+mainThread.isAlive());
		System.out.println("线程是否守护线程：\t"+mainThread.isDaemon());
		
		
	}
	
	public static void main(String[] args) {
		ThreadPriority two = new ThreadPriority();
		for(int i=0;i<5;i++)
		{
			new Thread(two,"第（"+i+")个线程").start();
		}
		//返回当前正在执行的线程对象，此处获取我们的主线程
		System.out.println("我是主线程。。。");
		Thread curThread = Thread.currentThread();
		System.out.println("主线程名称：\t"+curThread.getName());
		System.out.println("主线程组活动线程数：\t"+Thread.activeCount());
		System.out.println("主线程标识符：\t"+curThread.getId());
		System.out.println("主线程优先级：\t"+curThread.getPriority());
		System.out.println("主线程状态：\t"+curThread.getState());
		System.out.println("主线程所在线程组：\t"+curThread.getThreadGroup());
		System.out.println("主线程是否处于活动状态：\t"+curThread.isAlive());
		System.out.println("主线程是否守护线程：\t"+curThread.isDaemon());
		
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
